package com.example.autopia.view.Adapters

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import androidx.recyclerview.widget.RecyclerView
import com.example.autopia.R

class OnboardImgAdapter(private val images: Array<Int>) :
    RecyclerView.Adapter<OnboardImgAdapter.OnboardImgViewHolder>() {

    override fun getItemCount(): Int {
        return images.size
    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): OnboardImgViewHolder {
        val inflater = LayoutInflater.from(parent.context)
        val view = inflater.inflate(R.layout.viewholder_onboard_img_item, parent, false)
        return OnboardImgViewHolder(view)
    }

    override fun onBindViewHolder(holder: OnboardImgViewHolder, position: Int) {
        val imageResId = images[position]
        holder.img.setImageResource(imageResId)
    }

    class OnboardImgViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
        val img: ImageView = itemView.findViewById(R.id.iv_img)
    }

}
